import req from '@/utils/request'

const page_size = 20

export const getActivity = (page) => {
  return new Promise((resolve, reject) => {
    req({
      url: '/gxa/admin/getAuditedActivity',
      method: 'post',
      data: JSON.stringify({
        page,
        page_size
      })
    }).then(res => {
      if (res.data === null) reject(res)
      resolve(res)
    })
  })
}

export const checkActivity = (activity_id, pass) => {
  return new Promise((resolve, reject) => {
    req({
      url: '/gxa/admin/AuditedActivity',
      method: 'post',
      data: JSON.stringify({
        activity_id,
        pass
      })
    }).then(res => {
      if (res.code !== 0) reject()
      resolve(res)
    })
  })
}

export const getCheckedActivity = (page) => {
  return new Promise((resolve, reject) => {
    req({
      url: '/gxa/admin/gets/activity',
      method: 'post',
      data: JSON.stringify({
        page,
        page_size
      })
    }).then(res => {
      if (res.data === null) reject(res)
      resolve(res)
    })
  })
}

export const getActivityFlow = (activity_id) => {
  return new Promise((resolve, _reject) => [
    req({
      url: '/gxa/admin/gets/activity/flow',
      method: 'post',
      data: JSON.stringify({ activity_id })
    }).then(res => {
      resolve(res)
    })
  ])
}
